package org.jeecg.modules.relation.relcourschetempapp.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.relation.relcourschetempapp.entity.RelCourScheTempApp;
import org.jeecg.modules.relation.relcourschetempapp.mapper.RelCourScheTempAppMapper;
import org.jeecg.modules.relation.relcourschetempapp.service.IRelCourScheTempAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;
import java.util.List;

/**
 * @Description: rel_cour_sche_temp_app
 * @author: baochangrong
 * @Date: 2022-02-17
 * @Version: V1.0
 */
@Service
public class RelCourScheTempAppServiceImpl extends ServiceImpl<RelCourScheTempAppMapper, RelCourScheTempApp> implements IRelCourScheTempAppService {

    @Autowired
    private RelCourScheTempAppMapper courScheTempAppMapper;

    @Override
    public IPage<RelCourScheTempApp> allList(Page<RelCourScheTempApp> page, RelCourScheTempApp relCourScheTempApp) {
        List<RelCourScheTempApp> list = courScheTempAppMapper.queryAll(page, relCourScheTempApp);
        for (RelCourScheTempApp courScheTempApp : list) {
            int type = courScheTempApp.getRelObjTtype();
            if (1 <= type && type <= 5) {
                String objectName = courScheTempAppMapper.queryObjectNameByObjectId(type, courScheTempApp.getRelObjId());
                courScheTempApp.setObjectName(objectName);
            }
        }
        return page.setRecords(list);
    }

    @Override
    public int batchInsert(RelCourScheTempApp relCourScheTempApp) {
//        List<String> list = Arrays.asList(relCourScheTempApp.getObjIdList().split(","));
//        System.out.println(String objIdList , );
        return 0;
    }
}
